<template>
  <div class="app-container">
    <!--    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item label="危险废物名称" prop="wxfwjcName">
            <el-input
              v-model="queryParams.wxfwjcName"
              placeholder="请输入危险废物名称"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="种类" prop="wxfwjcZl">
            <el-input
              v-model="queryParams.wxfwjcZl"
              placeholder="请输入种类"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="危险特性" prop="wxfwjcTx">
            <el-input
              v-model="queryParams.wxfwjcTx"
              placeholder="请输入危险特性"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="类别" prop="wxfwjcLb">
            <el-input
              v-model="queryParams.wxfwjcLb"
              placeholder="请输入类别"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="数量" prop="wxfwjcNum">
            <el-input
              v-model="queryParams.wxfwjcNum"
              placeholder="请输入数量"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="包装方式" prop="wxfwjcBzfs">
            <el-input
              v-model="queryParams.wxfwjcBzfs"
              placeholder="请输入包装方式"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="禁忌" prop="wxfwjcJj">
            <el-input
              v-model="queryParams.wxfwjcJj"
              placeholder="请输入禁忌"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="应急措施" prop="wxfwjcYjcs">
            <el-input
              v-model="queryParams.wxfwjcYjcs"
              placeholder="请输入应急措施"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="发运人" prop="wxfwjcFyr">
            <el-input
              v-model="queryParams.wxfwjcFyr"
              placeholder="请输入发运人"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="承运人" prop="wxfwjcCyr">
            <el-input
              v-model="queryParams.wxfwjcCyr"
              placeholder="请输入承运人"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="发运地" prop="wxfwjcFyd">
            <el-input
              v-model="queryParams.wxfwjcFyd"
              placeholder="请输入发运地"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="发运时间" prop="wxfwjcFyTime">
            <el-input
              v-model="queryParams.wxfwjcFyTime"
              placeholder="请输入发运时间"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="接收人" prop="wxfwjcJsr">
            <el-input
              v-model="queryParams.wxfwjcJsr"
              placeholder="请输入接收人"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="接收时间" prop="wxfwjcJsTime">
            <el-input
              v-model="queryParams.wxfwjcJsTime"
              placeholder="请输入接收时间"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="处置方式" prop="wxfwjcCzfs">
            <el-input
              v-model="queryParams.wxfwjcCzfs"
              placeholder="请输入处置方式"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="入库暂存视频" prop="wxfwjcRkVideo">
            <el-input
              v-model="queryParams.wxfwjcRkVideo"
              placeholder="请输入入库暂存视频"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="及时处置视频" prop="wxfwjcJsVideo">
            <el-input
              v-model="queryParams.wxfwjcJsVideo"
              placeholder="请输入及时处置视频"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="危险废物入厂视频" prop="wxfwjcRcVideo">
            <el-input
              v-model="queryParams.wxfwjcRcVideo"
              placeholder="请输入危险废物入厂视频"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="危险废物转移联单" prop="wxfwjcZyLiandan">
            <el-input
              v-model="queryParams.wxfwjcZyLiandan"
              placeholder="请输入危险废物转移联单"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>-->

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="small"
          @click="handleAdd"
          v-hasPermi="['solidDispose:wxfwjcInfo:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="small"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['solidDispose:wxfwjcInfo:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="small"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['solidDispose:wxfwjcInfo:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="small"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['solidDispose:wxfwjcInfo:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="wxfwjcInfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <!--      <el-table-column label="危险废物接受信息ID" align="center" prop="wxfwjcId" />-->
      <el-table-column label="危险废物名称" align="center" prop="wxfwjcName"/>
      <el-table-column :formatter="typeFormat" label="种类" align="center" prop="wxfwjcZl"/>
      <el-table-column :formatter="typeFormat_tx" label="危险特性" align="center" prop="wxfwjcTx"/>
      <el-table-column label="类别" align="center" prop="wxfwjcLb"/>
      <el-table-column label="数量" align="center" prop="wxfwjcNum"/>
      <!--      <el-table-column label="包装方式" align="center" prop="wxfwjcBzfs" />
            <el-table-column label="禁忌" align="center" prop="wxfwjcJj" />
            <el-table-column label="应急措施" align="center" prop="wxfwjcYjcs" />-->
      <el-table-column label="发运人" align="center" prop="wxfwjcFyr"/>
      <el-table-column label="承运人" align="center" prop="wxfwjcCyr"/>
      <el-table-column label="发运地" align="center" prop="wxfwjcFyd"/>
      <el-table-column label="发运时间" align="center" prop="wxfwjcFyTime"/>
      <el-table-column label="接收人" align="center" prop="wxfwjcJsr"/>
      <el-table-column label="接收时间" align="center" prop="wxfwjcJsTime"/>
      <el-table-column label="处置方式" align="center" prop="wxfwjcCzfs"/>
      <!--      <el-table-column label="入库暂存视频" align="center" prop="wxfwjcRkVideo" />
            <el-table-column label="及时处置视频" align="center" prop="wxfwjcJsVideo" />
            <el-table-column label="危险废物入厂视频" align="center" prop="wxfwjcRcVideo" />-->
      <el-table-column label="转移联单" align="center" prop="wxfwjcZyLiandan"/>
      <!--      <el-table-column label="备注" align="center" prop="remark" />
            <el-table-column label="冗余字段" align="center" prop="other" />
            <el-table-column label="冗余字段" align="center" prop="otherOne" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="small"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['solidDispose:wxfwjcInfo:edit']"
          >修改
          </el-button>
          <el-button
            size="small"
            @click="handleDelete(scope.row)"
            v-hasPermi="['solidDispose:wxfwjcInfo:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改危险废物接受信息对话框 -->
    <el-dialog :title="title" :visible.sync="open"  append-to-body width="65%">
      <el-form ref="form" :model="form" :rules="rules" class="clearfix " label-width="140px">
        <div class="content-left" style="margin-left: 10%">
          <div class="title2"><span> </span>基本信息</div>
          <el-form-item label="危险废物名称" prop="wxfwjcName">
            <el-input v-model="form.wxfwjcName" placeholder="请输入危险废物名称"/>
          </el-form-item>
          <el-form-item label="种类" prop="wxfwjcZl">
            <el-select v-model="form.wxfwjcZl" placeholder="请选择">
              <el-option
                v-for="dict in typeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="危险特性" prop="wxfwjcTx">
            <el-select v-model="form.wxfwjcTx" placeholder="请选择">
              <el-option
                v-for="dict in typeOptions_tx"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="类别" prop="wxfwjcLb">
            <el-select v-model="form.wxfwjcLb" placeholder="请选择">
              <el-option
                v-for="dict in typeOptions_lb"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="数量" prop="wxfwjcNum">
            <el-input v-model="form.wxfwjcNum" placeholder="请输入数量" type="number"/>
          </el-form-item>
          <el-form-item label="包装方式" prop="wxfwjcBzfs">
            <el-input v-model="form.wxfwjcBzfs" placeholder="请输入包装方式"/>
          </el-form-item>
          <el-form-item label="禁忌" prop="wxfwjcJj">
            <el-input v-model="form.wxfwjcJj" placeholder="请输入禁忌"/>
          </el-form-item>
          <el-form-item label="应急措施" prop="wxfwjcYjcs">
            <el-input v-model="form.wxfwjcYjcs" placeholder="请输入应急措施"/>
          </el-form-item>
        </div>
        <div class="content-middle" style="margin-left: 15%">
          <div class="title2"><span> </span>接受信息</div>
          <el-form-item label="发运人" prop="wxfwjcFyr">
            <el-input v-model="form.wxfwjcFyr" placeholder="请输入发运人"/>
          </el-form-item>
          <el-form-item label="承运人" prop="wxfwjcCyr">
            <el-input v-model="form.wxfwjcCyr" placeholder="请输入承运人"/>
          </el-form-item>
          <el-form-item label="发运地" prop="wxfwjcFyd">
            <el-input v-model="form.wxfwjcFyd" placeholder="请输入发运地"/>
          </el-form-item>
          <el-form-item label="发运时间" prop="wxfwjcFyTime">
            <el-date-picker v-model="form.wxfwjcFyTime" clearable
                            placeholder="选择发运时间"
                            size="small"
                            style="width:100%"
                            type="date"
                            value-format="yyyy-MM-dd">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="接收人" prop="wxfwjcJsr">
            <el-input v-model="form.wxfwjcJsr" placeholder="请输入接收人"/>
          </el-form-item>
          <el-form-item label="接收时间" prop="wxfwjcJsTime">
            <el-date-picker v-model="form.wxfwjcJsTime" clearable
                            placeholder="选择接收时间"
                            size="small"
                            style="width:100%"
                            type="date"
                            value-format="yyyy-MM-dd">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="处置方式" prop="wxfwjcCzfs">
            <el-input v-model="form.wxfwjcCzfs" placeholder="请输入处置方式"/>
          </el-form-item>
          <el-form-item label="入库暂存视频" prop="wxfwjcRkVideo">
            <VideoUpload v-model="form.wxfwjcRkVideo" placeholder="请输入入库暂存视频"/>
          </el-form-item>
          <el-form-item label="及时处置视频" prop="wxfwjcJsVideo">
            <VideoUpload v-model="form.wxfwjcJsVideo" placeholder="请输入及时处置视频"/>
          </el-form-item>
          <el-form-item label="危险废物入厂视频" prop="wxfwjcRcVideo">
            <VideoUpload v-model="form.wxfwjcRcVideo" placeholder="请输入危险废物入厂视频"/>
          </el-form-item>
          <el-form-item label="转移联单" prop="wxfwjcZyLiandan">
            <FileUpload v-model="form.wxfwjcZyLiandan" />
          </el-form-item>
        </div>
        <!--        <el-form-item label="删除标志" prop="delFlag">
                  <el-input v-model="form.delFlag" placeholder="请输入删除标志" />
                </el-form-item>
                <el-form-item label="备注" prop="remark">
                  <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
                </el-form-item>
                <el-form-item label="冗余字段" prop="other">
                  <el-input v-model="form.other" type="textarea" placeholder="请输入内容" />
                </el-form-item>
                <el-form-item label="冗余字段" prop="otherOne">
                  <el-input v-model="form.otherOne" type="textarea" placeholder="请输入内容" />
                </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer tianjie_button" style="text-align: center;">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  addWxfwjcInfo,
  delWxfwjcInfo,
  exportWxfwjcInfo,
  getWxfwjcInfo,
  listWxfwjcInfo,
  updateWxfwjcInfo
} from "@/api/solidDispose/wxfwjcInfo";
import {validatetoTwoPoint,validatePhoneTwo,validateIdNo,validateEMail} from "@/api/validate/validate";

export default {
  name: "WxfwjcInfo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 危险废物接受信息表格数据
      wxfwjcInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        wxfwjcName: null,
        wxfwjcZl: null,
        wxfwjcTx: null,
        wxfwjcLb: null,
        wxfwjcNum: null,
        wxfwjcBzfs: null,
        wxfwjcJj: null,
        wxfwjcYjcs: null,
        wxfwjcFyr: null,
        wxfwjcCyr: null,
        wxfwjcFyd: null,
        wxfwjcFyTime: null,
        wxfwjcJsr: null,
        wxfwjcJsTime: null,
        wxfwjcCzfs: null,
        wxfwjcRkVideo: null,
        wxfwjcJsVideo: null,
        wxfwjcRcVideo: null,
        wxfwjcZyLiandan: null,
        other: null,
        otherOne: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        wxfwjcName: [
          {required: true, message: "名称不能为空", trigger: "blur"}
        ],
        wxfwjcZyLiandan: [
          {required: true,message: "请上传五联单",}
        ],
      },
      typeOptions:[],
      typeOptions_tx:[],
      typeOptions_lb:[],
    };
  },
  created() {
    this.getDicts("wxfwxt").then(response => {
      this.typeOptions = response.data;
    });
    this.getDicts("wxtx").then(response => {
      this.typeOptions_tx = response.data;
    });
    this.getDicts("wxfwlb").then(response => {
      this.typeOptions_lb = response.data;
    });
    this.getList();
  },
  methods: {
    typeFormat(row, column) {
      return this.selectDictLabel(this.typeOptions, row.wxfwjcZl);
    },
    typeFormat_tx(row, column) {
      return this.selectDictLabel(this.typeOptions_tx, row.wxfwjcTx);
    },
    typeFormat_lb(row, column) {
      return this.selectDictLabel(this.typeOptions_lb, row.wxfwjcLb);
    },
    /** 查询危险废物接受信息列表 */
    getList() {
      this.loading = true;
      listWxfwjcInfo(this.queryParams).then(response => {
        this.wxfwjcInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        wxfwjcId: null,
        wxfwjcName: null,
        wxfwjcZl: null,
        wxfwjcTx: null,
        wxfwjcLb: null,
        wxfwjcNum: null,
        wxfwjcBzfs: null,
        wxfwjcJj: null,
        wxfwjcYjcs: null,
        wxfwjcFyr: null,
        wxfwjcCyr: null,
        wxfwjcFyd: null,
        wxfwjcFyTime: null,
        wxfwjcJsr: null,
        wxfwjcJsTime: null,
        wxfwjcCzfs: null,
        wxfwjcRkVideo: null,
        wxfwjcJsVideo: null,
        wxfwjcRcVideo: null,
        wxfwjcZyLiandan: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        other: null,
        otherOne: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.wxfwjcId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加危险废物接受信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const wxfwjcId = row.wxfwjcId || this.ids
      getWxfwjcInfo(wxfwjcId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改危险废物接受信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.wxfwjcId != null) {
            updateWxfwjcInfo(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addWxfwjcInfo(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const wxfwjcIds = row.wxfwjcId || this.ids;
      this.$confirm('是否确认删除危险废物接受信息编号为"' + wxfwjcIds + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return delWxfwjcInfo(wxfwjcIds);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有危险废物接受信息数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        this.exportLoading = true;
        return exportWxfwjcInfo(queryParams);
      }).then(response => {
        this.download(response.msg);
        this.exportLoading = false;
      }).catch(() => {
      });
    }
  }
};
</script>
